<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>伪元素实现inline-block垂直居中</title>
</head>
<body>
  <div class="main">
    <div class="search">
      <form action="">
        <input type="text" placeholder="Xmo...">
        <div class="button">
          <i></i>
        </div>
      </form>
    </div>
  </div>
</body>
<style>
  .main {
    height: 100px;
    width: 40vw;
    border: yellowgreen solid 2px;
    text-align: center;
  }

  input {
    height: 30px;
  }

  div.search {
    display: inline-block;
    vertical-align: middle;
  }

  /* 设置伪元素，让search 元素和这个元素的中线对齐 */
  div.main::after{
    content: '';
    display: inline-block;
    height: 100%;
    width: 0;
    vertical-align: middle;
  }
</style>
</html>